import moment from 'moment';
export function formatTime(time) {
    return time ? moment(time).format('YYYY-MM-DD HH:mm:ss') : '';
}
const unitMap = {
    years: '年',
    months: '月',
    days: '日',
    hours: '小时',
    minutes: '分',
};
export function formatDuration(duration) {
    const years = {
        value: duration.years(),
        unit: unitMap.years,
    };
    const months = {
        value: duration.months(),
        unit: unitMap.months,
    };
    const days = {
        value: duration.days(),
        unit: unitMap.days,
    };
    const hours = {
        value: duration.hours(),
        unit: unitMap.hours,
    };
    const minutes = {
        value: duration.minutes(),
        unit: unitMap.minutes,
    };
    return [years, months, days, hours, minutes].reduce((prev, next) => {
        return prev + (next.value ? `${next.value}${next.unit}` : '');
    }, '');
}
